package com.aaa.service.impl;

import com.aaa.entity.Orderdetails;
import com.aaa.mapper.OrderdetailsDao;
import com.aaa.service.OrderdetailsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Orderdetails)表服务实现类
 *
 * @author makejava
 * @since 2022-01-12 13:27:05
 */
@Service("orderdetailsService")
public class OrderdetailsServiceImpl implements OrderdetailsService {
    @Resource
    private OrderdetailsDao orderdetailsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Orderdetails queryById(Integer id) {
        return this.orderdetailsDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<Orderdetails> queryAllByLimit(int offset, int limit) {
        return this.orderdetailsDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param orderdetails 实例对象
     * @return 实例对象
     */
    @Override
    public Orderdetails insert(Orderdetails orderdetails) {
        this.orderdetailsDao.insert(orderdetails);
        return orderdetails;
    }

    /**
     * 修改数据
     *
     * @param orderdetails 实例对象
     * @return 实例对象
     */
    @Override
    public Orderdetails update(Orderdetails orderdetails) {
        this.orderdetailsDao.update(orderdetails);
        return this.queryById(orderdetails.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.orderdetailsDao.deleteById(id) > 0;
    }
}